/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package test.ashen;

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Home
 */
public class Gestures {

    public void slide(int direction) {
        try {
            Robot rb = new Robot();
            switch (direction) {
                case 1: {
                    rb.keyPress(KeyEvent.VK_LEFT);
                    rb.keyRelease(KeyEvent.VK_LEFT);
                }
                case 2: {
                    rb.keyPress(KeyEvent.VK_RIGHT);
                    rb.keyRelease(KeyEvent.VK_RIGHT);
                }
                case 3: {
                    rb.keyPress(KeyEvent.VK_UP);
                    rb.keyRelease(KeyEvent.VK_UP);
                }
                case 4: {
                    rb.keyPress(KeyEvent.VK_DOWN);
                    rb.keyRelease(KeyEvent.VK_DOWN);
                }

            }
        } catch (AWTException ex) {
            Logger.getLogger(Gestures.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void scroll(int distance) {
        try {
            Robot rb = new Robot();
            rb.mouseWheel(distance);
        } catch (AWTException ex) {
            Logger.getLogger(Gestures.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    public void zooming(int factor) {
        try {
            Robot rb = new Robot();
            if (factor > 0) {
                //Zoom in
                rb.keyPress(KeyEvent.VK_CONTROL);
                rb.keyPress(KeyEvent.VK_SHIFT);
                rb.keyPress(KeyEvent.VK_EQUALS);
                rb.keyRelease(KeyEvent.VK_CONTROL);
                rb.keyRelease(KeyEvent.VK_SHIFT);
                rb.keyRelease(KeyEvent.VK_EQUALS);
            } else {
                //Zoom out
                rb.keyPress(KeyEvent.VK_CONTROL);
                rb.keyPress(KeyEvent.VK_SHIFT);
                rb.keyPress(KeyEvent.VK_MINUS);
                rb.keyRelease(KeyEvent.VK_CONTROL);
                rb.keyRelease(KeyEvent.VK_SHIFT);
                rb.keyRelease(KeyEvent.VK_MINUS);

            }
        } catch (AWTException ex) {
            Logger.getLogger(Gestures.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public static void main(String[] args) {

//        Scanner snr = new Scanner(System.in);
//        Gestures gs = new Gestures();
//        while(true){
//            int i=1;
//            gs.scroll(i);
//            i++;
//            i=-i;

        Test ts = new Test();
        new Thread(ts).start();

    }
}



